package binary_tree.sort;

import java.util.Arrays;
import java.util.Random;

public class sortTest {
    public static void main(String[] args) {
        sevenSort sort = new sevenSort();
        int n = 10000;
        int[] data1 = new int[n];
        int[] data2;
        Random random = new Random( );
        for (int i = 0; i < data1.length; i++) {
            data1[i] = random.nextInt(Integer.MAX_VALUE);
        }
        data2 = Arrays.copyOf(data1, n);
        long start = System.nanoTime();
        long end;
        sort.bubbleSort(data1);
        if(isSoreted(data1)){
            end=System.nanoTime();
            System.out.println("bubbleSort共耗时"+(end-start)/100000+"ms");
        }
      start=System.nanoTime();
        sort.heapSort(data2);
        if(isSoreted(data2)){
            end=System.nanoTime();
            System.out.println("heapSort共耗时"+(end-start)/100000+"ms");
        }
    }
        public static boolean isSoreted ( int[] arr){
            for (int i = 0; i < arr.length - 1; i++) {
                if (arr[i] > arr[i + 1]) {
                    return false;
                }
            }
            return true;
        }
}

//        int[] arr={2,4,1,5,7,6,8,3,9};
//        sevenSort sort=new sevenSort();
//        sort.bubbleSort(arr);
//        System.out.println(Arrays.toString(arr));
//    }